package lab03.test05;

import java.io.*;

public class Test05 {
    public static void main(String[] args) {
        BufferedWriter writer=null;
        BufferedReader reader=null;
        String s="";
        try {
            writer=new BufferedWriter(new FileWriter("D:\\123.txt"));
            writer.write("qert");
        } catch (IOException e) {
            e.printStackTrace();
        }

        finally {
            try {
                writer.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
            try {
                reader=new BufferedReader(new FileReader("D:\\123.txt"));
                while (true){
                    s=reader.readLine();
                 if (reader.readLine() == null){
                     break;
                 }
                }
                System.out.println("加密后输出为"+s);
                String[] s1=new String[s.length()];
                StringBuffer str=new StringBuffer();//声明连接字符串的方法
                for (int i=0;i<s.length();i++) {
                    s1[i] = new String(String.valueOf((char)(s.charAt(i) - 1)));
                                  str.append(s1[i]);
                }
                System.out.println("解密后输出为"+str.toString());//连接字符串

            } catch (FileNotFoundException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
finally {
                try {
                    reader.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }

    }
}
